home *** CD-ROM | disk | FTP | other *** search
- /*
- DispCtrl.h
-
- Display Controller routines for Graphic Elements
-
- Copyright 1994 by Al Evans. All rights reserved.
-
- 3/7/94
-
- Updated 5/25/95 for Graphic Elements version 3.0
-
- Updated 11/29/95 for GE for Windows95 1.0 -- AE
-
- */
-
- #ifndef DISPCTRL
- #define DISPCTRL
-
- #include "Defs.h"
- #include "GETimer.h"
- #include "GELoaders.h"
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
-
- // Creation of new GEWorld
-
- /*
- Returns pointer to a new GEWorld. This world covers the area of worldPort
- specified by worldRect (in port coordinates), if scale is scaleOneToOne.
-
- Scale determines the interpretation of the position and size of worldRect
- within worldPort. Briefly, if a GEWorld has a certain position and size in
- a GrafPort at scaleOneToOne, that GEWorld will have the same *relative* position
- and size, if the horizontal and vertical dimensions of the GrafPort are halved,
- at a scale of 0x00008000 (0.5 in fixed-point notation).
-
- If it is not nil, worldColors must be a handle to a color table appropriate
- for an 8-bit depth.
-
- */
-
- GEWorldPtr NewGEWorld(GrafPtr worldPort, Rect *worldRect, Fixed scale, CTabHandle worldColors);
-
-
- // Destruction of a GEWorld
-
- /*
- Disposes of a world and everything in it.
- */
-
- void DisposeGEWorld(GEWorldPtr world);
-
-
- // Management of a GEWorld
-
- /*
- Set default loader function for world. If no loader is specified when a new
- Graphic Element is created, this function is used.
-
- In a newly-created world, this loader function is one which creates an offscreen
- graphics environment and loads one or more PICTS from an open resource fork into it
- (Mac version), or loads one or more .BMP files named Pn.BMP, where "n" is a number
- analogous to the resource number of a Mac PICT (Windows 95 version).
- */
-
- void SetDefaultLoadFunc(GEWorldPtr world, GraphicLoadFunc loader);
-
- /*
- Set frame post-processing function and data for world. If this function is
- present, it will be called after every frame update.
- */
-
- void SetPostProcFunc(GEWorldPtr world, FramePostProcFunc postProcFunc, Ptr postProcData);
-
- /*
- Activate or deactivate an individual world
- */
-
- void ActivateWorld(GEWorldPtr world, Boolean turnItOn);
-
- /*
- Get and set projection rate
- These are NOT very useful, but MAY improve performance in some situations on
- slower machines.
- */
-
- void SetProjectionRate(GEWorldPtr world, short newMSPerFrame);
-
- short GetProjectionRate(GEWorldPtr world);
-
-
- /*
- Manipulate world coordinate system;
- */
-
- /*
- GetGEWorldFocus and SetGEWorldFocus should be used to "bracket" calls to
- FocusOnGEWorld, in order to save and restore the previous focus.
- */
-
- void GetGEWorldFocus(GEWorldPtr world, Point *currFocus);
- void SetGEWorldFocus(GEWorldPtr world, Point newFocus);
-
- /*
- Sets focus, i.e. coordinate system, to that of world
- */
-
- void FocusOnGEWorld(GEWorldPtr world);
-
- /*
- Move an entire GEWorld relative to its window
- */
-
- void MoveGEWorld(GEWorldPtr world, short dh, short dv);
- void MoveGEWorldTo(GEWorldPtr world, short h, short v);
-
- /*
- Scale a distance to the current world's worldScale.
- This is necessary ONLY in creating new Graphic Elements,
- for determining size and position within a world.
-
- Returns value * world->worldScale / 65536. If result is 0, returns
- 1 if value was positive, -1 if value was negative.
- */
-
- short ScaleToWorld(GEWorldPtr world, short value);
-
- /*
- Generate a frame showing the world in its current state and display it on the screen.
- Should be called frequently from application program, for example once each time
- through the main event loop or message loop.
-
- If invalidate is true, the entire world is redrawn. Otherwise, only the changed
- portions of world are updated.
- */
-
- // If world manager is in use for world, this will update all worlds registered with manager
- void DoWorldUpdate(GEWorldPtr world, Boolean invalidate);
-
- // Updates ONLY the specified GEWorld
- void Update1GEWorld(GEWorldPtr world, Boolean invalidate);
-
- /*
- Call from event/message handler when mouse down in the window containing world.
- Returns true if mouseDown was handled by a sensor, false otherwise.
- */
-
- // If world manager is in use for world, this will check sensors
- // in all worlds registered with manager
- Boolean MouseDownInSensor(GEWorldPtr world, Point gMousePt);
-
- // Checks sensors in ONLY the specified GEWorld
- Boolean MouseDownIn1World(GEWorldPtr world, Point gMousePt);
-
- //Services provided by Display Controller for Graphic Elements
-
- //Creation and destruction
-
- /*
- Low-level element creation. This function allocates an element, calls its
- GraphicLoadFunc proc (if any), and links it into the world. In itself, it
- initializes only the fields element->objectID and element-<drawPlane (in
- addition to those initialized by the GraphicLoadFunc).
-
- It is normally called only from a higher-level creation function.
- */
-
- GrafElPtr NewGrafElement(GEWorldPtr world, OSType id, short plane, short elemSize,
- GraphicLoadFunc loadProc, short resStart, short nRsrcs);
-
- /*
- Unlinks a graphic element from its world and disposes of it. Calls element's
- cleanupProc, if any. Recursively disposes of element's slaveGrafEl(s). If element
- has a masterGrafEl, sets masterGrafEl->slaveGrafEl to nil.
- */
-
- void DisposeGrafElement(GEWorldPtr world, OSType objectID);
-
- //Access
-
- /*
- Returns individual element with ID objectID
- */
-
- GrafElPtr FindElementByID(GEWorldPtr world, OSType objectID);
-
- /*
- Returns first element with drawPlane == plane. For collision checking, etc.
- */
-
- GrafElPtr ElementsInPlane(GEWorldPtr world, short plane);
-
- //Control
-
- /*
- ShowElement shows or hides a graphic element, depending on the value of showIt
- */
-
- void ShowElement(GEWorldPtr world, OSType elementID, Boolean showIt);
-
- /*
- Test whether element is presently visible
- */
-
- Boolean ElementVisible(GEWorldPtr world, OSType elementID);
-
- /*
- Move graphic elements
- */
-
- void MoveElement(GEWorldPtr world, OSType elementID, short dh, short dv);
- void MoveElementTo(GEWorldPtr world, OSType elementID, short h, short v);
-
- // Alternate interface: avoid lookup when GrafElPtr already available, for example
- // in Autochange procedures.
- // For PtrMoveElementTo(), h and v are in absolute pixels if doScale is false
-
- void PtrMoveElement(GEWorldPtr world, GrafElPtr element, short dh, short dv);
- void PtrMoveElementTo(GEWorldPtr world, GrafElPtr element, short h, short v, Boolean doScale);
-
- /*
- Sets element's plane to newPlane
- */
-
- void SetElementPlane(GEWorldPtr world, OSType elementID, short newPlane);
-
- /*
- Set element's autochange parameters
- */
-
- void SetAutoChange(GEWorldPtr world, OSType elementID, AutoChangeProc changeProc,
- Ptr changeData, short changeIntrvl);
-
- /*
- Set element's collision parameters. No collision if collidePlane == 0
- */
-
- void SetCollision(GEWorldPtr world, OSType elementID, CollisionProc collideProc,
- short collidePlane);
-
- /*
- Set element's custom dispose proc.
- */
-
- void SetCleanupProc(GEWorldPtr world, OSType elementID, CleanupProc elemCleanup);
-
- // Miscellaneous sensor services
-
- // Add sensor to world's sensor list and make it active
- void AddSensorToList(GEWorldPtr world, OSType id, Rect *sensorRect);
-
- // Remove sensor from world's sensor list and make it inactive
- void RemoveSensorFromList(GEWorldPtr world, OSType id);
-
- // Set sensor's actionProc to newAction
- void SetSensorAction(GEWorldPtr world, OSType sensorID, SensorAction newAction);
-
- // Get element's entry in world->sensorList, if any
- SListEntryPtr FindSensorListEntry(GEWorldPtr world, OSType sensorID);
-
- /*
- If anything in a world is changed from OUTSIDE the Graphic Elements system,
- call this procedure with the affected rectangle.
- */
-
- void ChangedRect(GEWorldPtr world, Rect *chgdRect);
-
- /*
- Windows/DIB version ONLY!
- Update palettes of all worlds to newPalette
- */
- #ifdef TARGET_IS_WIN95
- #if !USING_DIRECTDRAW
-
- // Notify Graphic Elements that the palette has been changed
- // Updates palette information for all worlds on world list
- void GEPaletteChanged(GEWorldPtr world, HPALETTE newPalette);
-
- #endif
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
-
- #endif
-